<template>
  <div>
    <CityHeader />
    <CitySerach :cities="cities" />
    <CityList :cities="cities"
              :hot="hotCities"
              :letter="letter" />
    <CityAlphabet :cities="cities"
                  @change="handleLetterChange" />
  </div>
</template>

<script>
import axios from "axios"
import CityHeader from "@/components/City/CityHeader.vue"
import CitySerach from "@/components/City/CitySerach.vue"
import CityList from "@/components/City/List.vue"
import CityAlphabet from "@/components/City/Alphabet.vue"
export default {
  name: "City",
  components: {
    CityHeader,
    CitySerach,
    CityList,
    CityAlphabet
  },
  data () {
    return {
      cities: {},
      hotCities: [],
      letter: ""
    }
  },
  methods: {
    handleLetterChange (letter) {
      this.letter = letter
      //  console.log('letter--' + letter)
    },
    getCityInfo () {
      axios.get("/api/city.json").then(this.getHomeInfoSucc)
    },
    getHomeInfoSucc (res) {
      res = res.data
      if (res.ret && res.data) {
        const data = res.data
        this.cities = data.cities
        this.hotCities = data.hotCities
      }
    }
  },
  mounted () {
    this.getCityInfo()
  }
}
</script>

<style>
</style>
